package io.github.maojian.bianrysearch;

import org.junit.Test;

/**
 * @Auther: jian.mao
 * @Date: 2022-06-23 16:40
 * @Description: https://leetcode.cn/problems/find-the-distance-value-between-two-arrays/
 */
public class Q1358 {
    public int findTheDistanceValue(int[] arr1, int[] arr2, int d) {
        int result = 0;
        for (int i = 0; i < arr1.length; i++) {
            int curArr1Num = arr1[i];
            for (int j = 0; j < arr2.length; j++) {
                if (Math.abs(curArr1Num - arr2[j]) <= d) {
                    result++;
                    break;
                }
            }
        }

        return arr1.length - result;
    }

    @Test
    public void test() {
        int[] arr1 = new int[]{4,5,8};
        int[] arr2 = new int[]{10,9,1,8};
        int d = 2;
        System.out.println(findTheDistanceValue(arr1, arr2, d));
    }
}
